<?php
	//定义常量，使用自己的函数
	require("config/common.php");
	$admin_id = $_COOKIE['admin_id'];
	$action = $_GET['action'];
	$adminc = new admin();

	//验证原密码
	if('isOldPwd' == $action){
		$pwd = $_GET['oldpwd'];
		$pwd = md5($pwd);
		$where = ' AND `pwd` = "'.$pwd.'" AND id = "'.$admin_id.'"';
		$list = $adminc->adminList($where);
		$info = $list['result'][0];
		if($info['id'] > 0){
			die('true');
		}else{
			die('false');
		}
	}

	//管理员用户名唯一
	if('adminNameOnly' == $action){
		$username = $_GET['username'];
		$oldId = $_GET['oid'] != '' ? $_GET['oid'] : 0;
		$where = ' AND name ="'.$username.'" AND id !="'.$oldId.'"';
		$list = $adminc->adminList($where);
		$info = $list['result'][0];
		if($info['id'] > 0){
			die('false');
		}else{
			die('true');
		}
	}

	//相册删除
	if('albumDel' == $action){
		$table_name = 'album';
		$img_id = $_POST['img_id'];
		$res = $commonc->del($table_name,$img_id.',','','id');
		die($res);
	}

	//排序
	if('sort' == $action){
		$table_name = 'album';
		if($_POST['type']=='up') $type = "prev";
		if($_POST['type']=='down') $type = "next";
		$sort = $commonc->sortChange($table_name, $_POST['id'], $type);
		echo $sort['id'];
		exit();
	}
?>